# -*- coding: UTF8 -*-
# Author: Sakurazaki
# (Aitor Martin. @arienai_ne - sakurazaki.setsunita@gmail.com)

import pygame.transform

from vector2d import Vector2D
from imageloader import loadImage
from paths import TEXTURES

class State(object):
    # Entity State

    # Default
    IDLE = 0

    # Minions
    FLOAT = 1
    WALK = 2

    # Island
    GROW = 3
    DECAY = 4

    # Update
    DESTROY = 5
    DIE = 6
    

class Entity(object):

    name = "Entity"

    # Initialization of common Entity Interface
    def __init__(self, texture):

        # Game vars
        self.state = State.IDLE

        # Graphics vars
        self.image = loadImage(TEXTURES + texture)
        self.surface = self.image
        self.rect = self.surface.get_rect()
        self.pos = Vector2D()
        self.rect.center = self.pos.get()
        self.size = 1.0

    # Functions to be fill by children
    def update(self, delta):
        "Update entity state"
        pass

    def render(self):
        "Prepare surface for fast rendering"
        pass

    # Common functions
    def setPosition(self, x, y=0):
        self.pos = Vector2D(x, y)
        
    def move(self, dx, dy):
        "Move x and y from your pos"
        self.pos += (dx, dy)

    def scale(self):
        "Resize the entity"
        self.surface = pygame.transform.scale(self.surface, (int(self.surface.get_width()* self.size), int(self.surface.get_height()* self.size)))
